package leecode

func distanceTraveled(mainTank int, additionalTank int) int {
	var result int
	for mainTank >= 5 && additionalTank > 0 {
		mainTank = mainTank - 5
		result += 5 * 10
		if additionalTank >= 1 {
			mainTank += 1
			additionalTank = additionalTank - 1
		}
	}
	result += mainTank * 10
	return result
}
